<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="css/style.css"/>
    <link href="assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/ace.min.css" />
    <link rel="stylesheet" href="font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="assets/js/typeahead-bs2.min.js"></script>
    <script src="assets/js/jquery.dataTables.min.js"></script>
    <script src="assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="assets/layer/layer.js" type="text/javascript" ></script>
    <script src="js/lrtk.js" type="text/javascript" ></script>
    <script src="assets/layer/layer.js" type="text/javascript"></script>
    <script src="assets/laydate/laydate.js" type="text/javascript"></script>
    <title>管理员</title>
</head>

<body>
    <!--添加管理员-->
    <div id="add_administrator_style" class="add_menber">
        <form action="${pageContext.request.contextPath}/back/updateManager??" method="post" id="form-admin-add">
            <div class="form-group">
                <label class="form-label"><span class="c-red">*</span>管理员ID：</label>
                <div class="formControls">
                    <input type="text" class="input-text"  value="${editManager.mgr_id}" id="mgr_id" name="mgr_id" datatype="*2-16" readonly>
                </div>
                <div class="col-4"> <span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label"><span class="c-red">*</span>登录名：</label>
                <div class="formControls">
                    <input type="text" class="input-text"  value="${editManager.login_name}" id="login_name" name="login_name" datatype="*2-16" nullmsg="用户名不能为空">
                    <span id="errorName" style="color: red"></span>
                </div>
                <div class="col-4"> <span class="Validform_checktip"></span></div>
            </div>
            <script>
                $("#login_name").change(function (){
                    console.log("失去焦点了")
                    var name=$("#login_name").val();
                    $.ajax({
                        type: "post",
                        url:getPageContext()+"/back/checkLoginName",
                        data:"login_name="+name,
                        async:true,
                        success:function (json){
                            console.log("ajax执行成功了"+json)
                            if (json!="0"&&json!="${editManager.login_name}"){
                                $("#errorName").html("这个名字太受欢迎了，请重新输入名字！")
                            }else {
                                $("#errorName").html("")
                            }
                        }
                    })
                })

                function getPageContext() {
                    //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
                    var curWwwPath = window.document.location.href;
                    //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
                    var pathName = window.document.location.pathname;
                    var pos = curWwwPath.indexOf(pathName);
                    //获取主机地址，如： http://localhost:8083
                    var localhostPaht = curWwwPath.substring(0, pos);
                    //获取带"/"的项目名，如：/uimcardprj
                    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
                    // 打印获取当前项目根路径
                    return (localhostPaht + projectName);
                }
            </script>
            <div class="form-group">
                <label class="form-label"><span class="c-red">*</span>初始密码：</label>
                <div class="formControls">
                    <input type="password" placeholder="密码" name="login_pwd" placeholder="请输入密码" autocomplete="off" value="" class="input-text" datatype="*6-20" nullmsg="密码不能为空">
                </div>
                <div class="col-4"> <span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label "><span class="c-red">*</span>确认密码：</label>
                <div class="formControls ">
                    <input type="password" placeholder="确认新密码" autocomplete="off" placeholder="请确认密码" class="input-text Validform_error" errormsg="您两次输入的新密码不一致！" datatype="*" nullmsg="请再输入一次新密码！" recheck="login_pwd" id="newpassword2" name="newpassword2">
                </div>
                <div class="col-4"> <span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label "><span class="c-red">*</span>性别：</label>
                <div class="formControls  skin-minimal">
                    <label style="display:none"><input name="mgr_gender" type="radio" class="ace" checked="checked" value="-1" ><span class="lbl">保密</span></label>&nbsp;&nbsp;
                    <label><input name="mgr_gender" type="radio" class="ace" value="1"><span class="lbl" >男</span></label>&nbsp;&nbsp;
                    <label><input name="mgr_gender" type="radio" class="ace" value="0" ><span class="lbl" >女</span></label>
                </div>
                <div class="col-4"> <span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label "><span class="c-red">*</span>手机：</label>
                <div class="formControls ">
                    <input type="text" class="input-text" value="${editManager.mgr_tel}" placeholder="" id="mgr_tel" name="mgr_tel" datatype="m" nullmsg="手机不能为空">
                    <span id="errorTel" style="color: red"></span>
                </div>
                <div class="col-4"> <span class="Validform_checktip"></span></div>
            </div>
            <script>
                $("#mgr_tel").change(function (){
                    console.log("失去焦点了")
                    var tel=$("#mgr_tel").val();
                    $.ajax({
                        type: "post",
                        url:getPageContext()+"/back/checkMgrTel",
                        data:"mgr_tel="+tel,
                        async:true,
                        success:function (json){
                            console.log("ajax执行成功了"+json)
                            if (json!="0"&&json!="${editManager.mgr_tel}"){
                                $("#errorTel").html("该电话号码已被注册！")
                            }else {
                                $("#errorTel").html("")
                            }
                        }
                    })
                })
            </script>
            <div class="form-group">
                <label class="form-label"><span class="c-red">*</span>邮箱：</label>
                <div class="formControls ">
                    <input type="text" class="input-text" value="${editManager.mgr_email}" placeholder="@" name="mgr_email" id="mgr_email" datatype="e" nullmsg="请输入邮箱！">
                    <span id="errorEmail" style="color: red"></span>
                </div>
                <div class="col-4"> <span class="Validform_checktip"></span></div>
            </div>
            <script>
                $("#mgr_email").change(function (){
                    console.log("失去焦点了")
                    var email = $("#mgr_email").val();
                    $.ajax({
                        type: "post",
                        url: getPageContext() + "/back/checkEmail",
                        data: "mgr_email=" + email,
                        async: true,
                        success: function (json) {
                            console.log("ajax执行成功了"+json)
                            if (json != "0"&&json!="${editManager.mgr_email}") {
                                $("#errorEmail").html("该邮箱已被使用！")
                            } else {
                                $("#errorEmail").html("")
                            }
                        }
                    })
                })
            </script>
            <div class="form-group">
                <label class="form-label">角色：</label>
                <div class="formControls "> <span class="select-box" style="width:150px;">
				<select class="select" name="role_id" size="1">
                    <option value="">--请选择管理员角色--</option>
                    <c:forEach items="${roleList}" var="role">
                        <option value="${role.role_id}">${role.role_name}</option>
                    </c:forEach>
					<%--<option value="0">超级管理员</option>
					<option value="1">管理员</option>
					<option value="2">栏目主辑</option>
					<option value="3">栏目编辑</option>--%>
				</select>
				</span> </div>
            </div>
            <div class="form-group" style="display:none" >
                <label class="form-label">备注：</label>
                <div class="formControls">
                    <textarea name="" cols="" rows="" class="textarea" placeholder="说点什么...100个字符以内" dragonfly="true" onkeyup="checkLength(this);"></textarea>
                    <span class="wordage">剩余字数：<span id="sy" style="color:Red;">100</span>字</span>
                </div>
                <div class="col-4"> </div>
            </div>
            <input class="btn btn-primary radius" type="submit" id="Add_Administrator" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
        </form>
    </div>
</div>
</body>
</html>



